﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jzy.Model.Desktop;

using Jzy.DAL.Desktop;

using Frame.Lib.Core.Base;
using Frame.Lib.Core.Config;

namespace Jzy.BLL.Desktop
{
    public class DesktopBO : CommonOperate<DesktopInfo>
    {
        private DesktopDAL _desktop;
        protected override BaseDAL DAL
        {
            get
            {
                return _desktop;
            }
        }
        public DesktopBO()
        {
            _desktop = new DesktopDAL();
        }

        /// <summary>
        /// 获取当前用户的桌面配置，如果没有则初始化
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public override DesktopInfo GetInfo(object id)
        {
            DesktopInfo info = base.GetInfo(id);
            if (info == null)
            {
                info = new DesktopInfo();
                SysConfigBO config = new SysConfigBO();
                SysConfigInfo cfgInfo = config.GetInfo(ConfigID.desktop.ToString());
                info.ID = (int)id;
                info.Modules = cfgInfo.Config;

                base.Save(info, true);
            }

            return info;
        }
    }
}
